package com.agritech.state;

import com.agritech.machine.AgriculturalMachineContext;

/**
 * 空闲状态类
 * 状态模式的具体状态实现
 */
public class IdleState implements MachineState {
    @Override
    public void start(AgriculturalMachineContext context) {
        System.out.println("农机 " + context.getMachine().getId() + " 从空闲状态启动");
        context.getMachine().setRunning(true); // 实际启动农机
        context.setState(new WorkingState());
    }

    @Override
    public void stop(AgriculturalMachineContext context) {
        System.out.println("农机 " + context.getMachine().getId() + " 已经是空闲（停止）状态");
    }

    @Override
    public void performTask(AgriculturalMachineContext context, String taskDetails) {
        System.out.println("农机 " + context.getMachine().getId() + " 为空闲状态，请先启动再执行任务");
    }

    @Override
    public void repair(AgriculturalMachineContext context) {
        System.out.println("农机 " + context.getMachine().getId() + " 进入维修状态");
        context.setState(new MaintenanceState());
    }
    
    @Override
    public String getStateName() {
        return "空闲";
    }
}